home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1997 December / PC Pro December 1997 CD-Rom coverdisc.iso / symantec / dbAnywh / JAVA.BIN / CLASSES.ZIP / sun / tools / tree / UnaryExpression.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-12-14  |  3.5 KB  |  124 lines

  1. package sun.tools.tree;
  2.  
  3. import java.io.PrintStream;
  4. import java.util.Hashtable;
  5. import sun.tools.java.CompilerError;
  6. import sun.tools.java.Constants;
  7. import sun.tools.java.Environment;
  8. import sun.tools.java.Type;
  9.  
  10. public class UnaryExpression extends Expression {
  11.    Expression right;
  12.  
  13.    UnaryExpression(int var1, int var2, Type var3, Expression var4) {
  14.       super(var1, var2, var3);
  15.       this.right = var4;
  16.    }
  17.  
  18.    public Expression order() {
  19.       if (((Expression)this).precedence() > this.right.precedence()) {
  20.          UnaryExpression var1 = (UnaryExpression)this.right;
  21.          this.right = var1.right;
  22.          var1.right = this.order();
  23.          return var1;
  24.       } else {
  25.          return this;
  26.       }
  27.    }
  28.  
  29.    void selectType(Environment var1, Context var2, int var3) {
  30.       throw new CompilerError("selectType: " + Constants.opNames[super.op]);
  31.    }
  32.  
  33.    public long checkValue(Environment var1, Context var2, long var3, Hashtable var5) {
  34.       var3 = this.right.checkValue(var1, var2, var3, var5);
  35.       int var6 = this.right.type.getTypeMask();
  36.       this.selectType(var1, var2, var6);
  37.       if ((var6 & 8192) == 0 && super.type.isType(13)) {
  38.          var1.error(super.where, "invalid.arg", Constants.opNames[super.op]);
  39.       }
  40.  
  41.       return var3;
  42.    }
  43.  
  44.    Expression eval(int var1) {
  45.       return this;
  46.    }
  47.  
  48.    Expression eval(long var1) {
  49.       return this;
  50.    }
  51.  
  52.    Expression eval(float var1) {
  53.       return this;
  54.    }
  55.  
  56.    Expression eval(double var1) {
  57.       return this;
  58.    }
  59.  
  60.    Expression eval(boolean var1) {
  61.       return this;
  62.    }
  63.  
  64.    Expression eval(String var1) {
  65.       return this;
  66.    }
  67.  
  68.    Expression eval() {
  69.       switch (this.right.op) {
  70.          case 61:
  71.             return this.eval(((BooleanExpression)this.right).value);
  72.          case 62:
  73.          case 63:
  74.          case 64:
  75.          case 65:
  76.             return this.eval(((IntegerExpression)this.right).value);
  77.          case 66:
  78.             return this.eval(((LongExpression)this.right).value);
  79.          case 67:
  80.             return this.eval(((FloatExpression)this.right).value);
  81.          case 68:
  82.             return this.eval(((DoubleExpression)this.right).value);
  83.          case 69:
  84.             return this.eval(((StringExpression)this.right).value);
  85.          default:
  86.             return this;
  87.       }
  88.    }
  89.  
  90.    public Expression inline(Environment var1, Context var2) {
  91.       return this.right.inline(var1, var2);
  92.    }
  93.  
  94.    public Expression inlineValue(Environment var1, Context var2) {
  95.       this.right = this.right.inlineValue(var1, var2);
  96.  
  97.       try {
  98.          return this.eval().simplify();
  99.       } catch (ArithmeticException var3) {
  100.          var1.error(super.where, "arithmetic.exception");
  101.          return this;
  102.       }
  103.    }
  104.  
  105.    public Expression copyInline(Context var1) {
  106.       UnaryExpression var2 = (UnaryExpression)((Node)this).clone();
  107.       if (this.right != null) {
  108.          var2.right = this.right.copyInline(var1);
  109.       }
  110.  
  111.       return var2;
  112.    }
  113.  
  114.    public int costInline(int var1) {
  115.       return 1 + this.right.costInline(var1);
  116.    }
  117.  
  118.    public void print(PrintStream var1) {
  119.       var1.print("(" + Constants.opNames[super.op] + " ");
  120.       this.right.print(var1);
  121.       var1.print(")");
  122.    }
  123. }
  124.